$(function(){
	var editor,dialog;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="content"]', {
		themeType : 'default',
		resizeType : 0,
		allowPreviewEmoticons : false,
		allowImageUpload : false,
		items : [
				'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons', 'image', 'link']
		});
		/*
		dialog = K.dialog({
							width:500,
							title:'娓╅Θ鎻愮ず',
							body : '<div style="margin:10px;"><strong>璇疯緭鍏ヤ功淇″唴瀹�/strong></div>',
							yesBtn : {
								name : '纭畾',
								click : function(e) {
										dialog.remove();
								}
							}	
						});*/
		
	});
	$("#form1").validate({
		rules:{
			name:{
				required:true
			},
			address:{
				required:true
			}
		},
		messages:{
			name:{
				required:"请输入收件人姓名"
			},
			address:{
				required:"请输入收件人地址"
			}
		},
		/* 设置验证触发事件 */  
		focusInvalid: false,   
        onkeyup: false,    
		/* 设置错误信息提示DOM */  
		errorPlacement: function(error, element) {       
			error.appendTo( element.parent());       
		},
		submitHandler:function(form) {
			if(!editor.isEmpty()){
				form.submit();
			} else {
				var dialog = KindEditor.dialog({
							width:300,
							height:100,
							title:'温馨提示',
							body : '<div style="margin:10px;"><strong>请输入书信内容</strong></div>',
							closeBtn : {
								name : '关闭',
								click : function(e) {
									dialog.remove();
								}
							},
							yesBtn : {
								name : '确定',
								click : function(e) {
									dialog.remove();
								}
							},
							noBtn : {
								name : '取消',
								click : function(e) {
									dialog.remove();
								}
							}
						});
			}
		}
	});
});
